const names: "TPQ" = "TPQ"
const age: 22 = 22
console.log(names, age)

type Direction = "left" | "right" | "top" | "bottom"
const l: Direction = "left"
const r: Direction = "right"
console.log(l, r)


/*
封装一个请求函数的方法
    type UrlType = string
    type MethodType = string
    function request(url: UrlType, method: MethodType): void {
        console.log(url, method)
    }

    request("TypeScript", "get")
 */

type UrlType = string
// 字面量类型
type MethodType = "post" | "get"

function request(url: UrlType, method: MethodType) {
    console.log(url, method)
}


type ConfigType = {
    url: string,
    method: string
}
const config: ConfigType = {
    url: "Typescript",
    method: "get",
}
// request(config.url, config.method) 错误  config.method是一个string类型 request函数的第二个参数需要的是一个string字面量类型的"get"

request(config.url, config.method as "get") // 将config.method类型断言成字面量"get"类型
